package com.googlecode.imanager.core.base.style;

import com.googlecode.imanager.client.bridge.style.IFont;
import com.googlecode.imanager.client.style.Color;
import com.googlecode.imanager.client.style.HorzAlignment;
import com.googlecode.imanager.client.style.VertAlignment;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class ComputedFont implements IFont, ComputedAttribute<IFont> {

    protected String name;
    protected Integer size;
    protected Color color;
    protected Boolean bold;
    protected Boolean italic;
    protected Boolean underline;
    protected Boolean strike;
    protected HorzAlignment horzAlignment;
    protected VertAlignment vertAlignment;

    public void mergeWith(IFont o){
        if (o == null){
            return;
        }
        
        if (o.getName() != null){
            name = o.getName();
        }
        if (o.getSize() != null){
            size = o.getSize();
        }
        if (o.getColor() != null){
            color = o.getColor();
        }
        if (o.getBold() != null){
            bold = o.getBold();
        }
        if (o.getItalic() != null){
            italic = o.getItalic();
        }
        if (o.getUnderline() != null){
            underline = o.getUnderline();
        }
        if (o.getStrike() != null){
            strike = o.getStrike();
        }
        if (o.getHorzAlignment() != null){
            horzAlignment = o.getHorzAlignment();
        }
        if (o.getVertAlignment() != null){
            vertAlignment = o.getVertAlignment();
        }
    }

    @Override
    public void copyFrom(IFont o) {
        if (o == null){
            name = null;
            size = null;
            color = null;
            bold = null;
            italic = null;
            underline = null;
            strike = null;
            horzAlignment = null;
            vertAlignment = null;
        } else {
            name = o.getName();
            size = o.getSize();
            color = o.getColor();
            bold = o.getBold();
            italic = o.getItalic();
            underline = o.getUnderline();
            strike = o.getStrike();
            horzAlignment = o.getHorzAlignment();
            vertAlignment = o.getVertAlignment();
        }
    }

    public String getName() {
        return name;
    }

    public Integer getSize() {
        return size;
    }

    public Color getColor() {
        return color;
    }

    public Boolean getBold() {
        return bold;
    }

    public Boolean getItalic() {
        return italic;
    }

    public Boolean getUnderline() {
        return underline;
    }

    public Boolean getStrike() {
        return strike;
    }

    public HorzAlignment getHorzAlignment() {
        return horzAlignment;
    }

    public VertAlignment getVertAlignment() {
        return vertAlignment;
    }
    
}
